home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_222 / plplot / src / source.zoo / plw3d.c < prev    next >
C/C++ Source or Header  |  1989-05-15  |  2KB  |  63 lines

  1. /* Set up a window for three-dimensional plotting. The data are mapped */
  2. /* into a box with world coordinate size "basex" by "basey" by "height", */
  3. /* with the base being symmetrically positioned about zero. Thus */
  4. /* the mapping between data 3-d and world 3-d coordinates is given by: */
  5.  
  6. /*   x = xmin   =>   wx = -0.5*basex */
  7. /*   x = xmax   =>   wx =  0.5*basex */
  8. /*   y = ymin   =>   wy = -0.5*basey */
  9. /*   y = ymax   =>   wy =  0.5*basey */
  10. /*   z = zmin   =>   wz =  0.0 */
  11. /*   z = zmax   =>   wz =  height */
  12.  
  13. /* The world coordinate box is then viewed from position "alt"-"az", */
  14. /* measured in degrees. For proper operation, 0 <= alt <= 90 degrees, */
  15. /* but az can be any value. */
  16.  
  17. #include "plplot.h"
  18. #include <math.h>
  19.  
  20. #define  dtr   0.01745329252
  21.  
  22. void plw3d(basex,basey,height,xmin0,xmax0,ymin0,ymax0,zmin0,zmax0,alt,az)
  23. float basex, basey, height, xmin0, xmax0, ymin0, ymax0, zmin0, zmax0;
  24. float alt, az;
  25. {
  26.       float xmin, xmax, ymin, ymax, zmin, zmax, d;
  27.       float cx, cy, saz, caz, salt, calt, zscale;
  28.  
  29.       int level;
  30.       glev(&level);
  31.       if (level < 3) fatal("Please set up 2-d window before calling PLW3D.");
  32.       if (basex <= 0.0 || basey <= 0.0 || height <= 0.0)
  33.               fatal("Invalid world coordinate boxsize in PLW3D.");
  34.       if (xmin0 == xmax0 || ymin0 == ymax0 || zmin0 == zmax0)
  35.               fatal("Invalid axis range in PLW3D.");
  36.       if (alt<0.0 || alt>90.0)
  37.               fatal("Altitude must be between 0 and 90 degrees in PLW3D.");
  38.  
  39.       d = 1.0e-5*(xmax0-xmin0);
  40.       xmax = xmax0 + d;
  41.       xmin = xmin0 - d;
  42.       d = 1.0e-5*(ymax0-ymin0);
  43.       ymax = ymax0 + d;
  44.       ymin = ymin0 - d;
  45.       d = 1.0e-5*(zmax0-zmin0);
  46.       zmax = zmax0 + d;
  47.       zmin = zmin0 - d;
  48.       cx = basex/(xmax-xmin);
  49.       cy = basey/(ymax-ymin);
  50.       zscale = height/(zmax-zmin);
  51.       saz = sin(dtr*az);
  52.       caz = cos(dtr*az);
  53.       salt = sin(dtr*alt);
  54.       calt = cos(dtr*alt);
  55.       
  56.       sdom(xmin,xmax,ymin,ymax);
  57.       srange(zscale,zmin,zmax);
  58.       sbase(basex,basey,0.5*(xmin+xmax),0.5*(ymin+ymax));
  59.  
  60.       sw3wc(cx*caz,-cy*saz,cx*saz*salt,cy*caz*salt,zscale*calt);
  61. }
  62.  
  63.